<h1>Admin Interface</h1>

<%= link_to 'Show All Admins', admin_path(:all_admins => true) %> |
<%= link_to 'Show All Moderators', admin_path(:all_mods => true) %>

<% form_for @user_search do |f| %>
  <%= f.label :username_like, "Find User:" %>
  <%= f.text_field :username_like %>
  <%= f.submit "Search" %>
<% end %>

<hr />

<% if !@users.nil?  %>
  <% @users.each do |user| %>
    <% form_for user, :url => {:action => "update" } do |f| %>
      Username: <%=h user.username %><br />
      Email:    <%=h user.email %><br />
      Roles:    <% for role in Role.all %>
                  <%= check_box_tag "user[role_ids][]", role.id, user.roles.include?(role) %>
                  <%=h role.name %>
                <% end %>
                <br />
      Posts:    <%=h user.posts_count %>  <%= link_to 'Show Posts' %><br />
      Edits:    <%=h user.edits_count %>  <%= link_to 'Show Edits' %><br />
                <%= link_to 'Show Edits' %><br />
      Active:   <%= check_box_tag "user[active][]", user.active, user.active? %><br />
      Banned:   <%= check_box_tag "user[banned][]", user.banned, user.banned? %><br />
      <%= f.hidden_field :id, :value => user.id %>
      <%= f.submit 'Update User' %> |
      <%= link_to 'Reset Pasword', admin_create_password_resets_path(:email => user.email) %> |
      <%= link_to 'Delete', user, :method => :delete, :confirm => "Are you sure?" %> 
    <% end %>
    <hr />
  <% end %>
<% end %>
